import React, { Component } from 'react';
import { Modal, Button, Form, Input, Spin } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import {connect} from 'react-redux'

// 导入自定义组件
import UpdateUserInfoForm from './updateUserInfoForm';
import updateUserPasswdForm from './updateUserPasswdForm';
// 导入自定义操作
import { ChangeUserinfoActivate } from '../../../../redux/actions/userinfo'
import { ChangeMasterTasksDataActivate } from '../../../../redux/actions/taskMasterManagePage';
import UpdateUserPasswdForm from './updateUserPasswdForm';


// 用户登录弹窗代码
class UpdateUserInfo extends Component {

    onClose = () => {
        const {ChangeUserinfoActivate, userinfoState} = this.props
        ChangeUserinfoActivate({
            activate: !userinfoState.activate,
            updateUserInfoAct: !userinfoState.updateUserInfoAct
        })}

    onOk = () => {
        const {ChangeUserinfoActivate, userinfoState} = this.props
        ChangeUserinfoActivate({
            updateUserPasswdAct: !userinfoState.updateUserPasswdAct
        })}
    
  render() {
    const { userinfoState, UpdateTaskMMPState } = this.props
    return (
      <div>
          <Modal
            // mask={true} // 遮盖层
            maskClosable={false} // 点击空白处不关闭
            // maskStyle = '#ff0000'
            visible={userinfoState.updateUserInfoAct}
            title={!userinfoState.updateUserPasswdAct ? "修改基本信息" : "修改密码"}
            onCancel={this.onClose}
            onOk = {this.onOk}
            okText= {userinfoState.updateUserPasswdAct ? "修改信息" : "修改密码"}
            cancelText="取消"
            // footer={[]}
          >
            {
                userinfoState.updateUserPasswdAct
                ?
                <UpdateUserPasswdForm />
                :
                <UpdateUserInfoForm />
            }
          </Modal>
      </div>
    );
  }
}

export default connect(
  state => ({
    userinfoState: state.UserInfoReducer.userinfo,
    UpdateTaskMMPState: state.TaskMasterManagePageReducer.updateTask,
  }),
  {
    ChangeUserinfoActivate,
    ChangeMasterTasksDataActivate,
  }
)(UpdateUserInfo)
